<template>
  <view>
    <u-navbar
      title="订单支付"
      :autoBack="true"
      :placeholder="true"
      leftIconColor="#ffffff"
      :titleStyle="{ color: '#ffffff' }"
      bgColor="#1D1D20"
      class="navBarHeight"
    />
    <view class="padding font-30">
      <view>订单号：{{ orderId }}</view>
      <view class="margin-tb-sm">订单金额： ￥{{ moneyTotal }}</view>
      <payMethod
        :payMethodList="payMethodList"
        :extend="extend"
        :orderId="orderId"
        :moneyTotal="Number(moneyTotal)"
      ></payMethod>
    </view>
  </view>
</template>

<script>
import { orderDetail, orderPayMethod } from "@/common/api/order.js";
import payMethod from "@/pages/order/components/payMethod";
export default {
  components: {
    payMethod,
  },
  data() {
    return {
      background: {
        backgroundColor: "#1D1D20",
      },
      payMethodList: [],
      timeout: 0,
      productCurrentPrice: 0,
      orderDetail: {},
      timer: null,
      mixedPaymentList: [],
      extend: {},
      orderId: null,
      productId: null,
      moneyTotal: null,
    };
  },
  onLoad(options) {
    this.productId = options.productId;
    this.orderId = options.orderId;
    this.moneyTotal = options.moneyTotal;
  },
  onShow() {
    this.getOrderPayMethod();
    let payAlipay = uni.getStorageSync("payAlipay") || false;
    if (payAlipay) {
      this.$msg("支付结果弹出", payAlipay);
      uni.switchTab({
        url: "/pages/my/my",
      });
    }
    let payWechat = uni.getStorageSync("payWechat") || false;
    if (payWechat) {
      uni.switchTab({
        url: "/pages/my/my",
      });
    }
  },
  methods: {
    // 订单详情
    getOrderDetail() {
      orderDetail(this.orderId).then((res) => {
        this.orderDetail = res.data || {};
        if (res.data?.orderStatus == 2) {
          if (this.orderDetail.productArea == 6) {
            uni.redirectTo({
              url: "/pages/my/coupon/eBayCoupon",
            });
          } else {
            uni.redirectTo({
              url: "/pages/order/orderList?tabIndex=" + 2,
            });
          }
        }
      });
    },
    // 获取支付方式
    getOrderPayMethod() {
      let data = {
        productIds: this.productId,
      };
      orderPayMethod(data).then((res) => {
        if (res.code === 200) {
          this.payMethodList = res.data || [];
          this.extend = res.extend || {};
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.amount-box {
  margin-top: 100rpx;
}
</style>
